package classes;

import utils.Date;
import business.ClassroomBusiness;
import exceptions.RepositoryException;

public class Visitant extends Storable implements Tableble
{
	private String	name;
	private Date	visitDate;
	private int		visitedClassId;
	private ClassroomBusiness classroomBusiness;

	public Visitant( String name, Date visitDate, int visitedClassId )
	{
		this.setName( name );
		this.setVisitDate( visitDate );
		this.setVisitedClassId( visitedClassId );
		try
		{
			this.classroomBusiness = new ClassroomBusiness();
		}
		catch ( RepositoryException e ) {}
	}

	public String getName()
	{
		return name;
	}

	public Date getVisitDate()
	{
		return visitDate;
	}

	public int getVisitedClassId()
	{
		return visitedClassId;
	}

	public void setName( String name )
	{
		this.name = name;
	}

	public void setVisitDate( Date visitDate )
	{
		this.visitDate = visitDate;
	}

	public void setVisitedClassId( int visitedClassId )
	{
		this.visitedClassId = visitedClassId;
	}

	@Override
	public String[] getHead()
	{
		String[] ret;
		
		ret = new String[] { "Id", "Nome", "Dia da Visita", "Classe" };
		
		return ret;
	}

	@Override
	public Object[] getRow()
	{
		Object[] ret;
		
		Classroom classroom = null;
		try
		{
			classroom = classroomBusiness.get( this.visitedClassId );
		}
		catch ( RepositoryException e ) {}
		
		ret = new Object[] { String.valueOf( this.getId() ), this.name, this.visitDate, classroom };
		
		return ret;
	}
}
